const INFO_KEY = 'shopping_user_info'
const HISTORY_KEY = 'shopping_history'

export const getInfo = () => {
  const defaultObj = { token: '', userId: '' }
  return JSON.parse(localStorage.getItem(INFO_KEY)) || defaultObj
}

export const setInfo = (obj) => {
  localStorage.setItem(INFO_KEY, JSON.stringify(obj))
}

export const removeInfo = () => {
  localStorage.removeItem(INFO_KEY)
}

export const gethistory = () => {
  const defaultObj = []
  return JSON.parse(localStorage.getItem(HISTORY_KEY)) || defaultObj
}

export const sethistory = (obj) => {
  localStorage.setItem(HISTORY_KEY, JSON.stringify(obj))
}

export const removehistory = () => {
  localStorage.removeItem(HISTORY_KEY)
}
